package logic

import (
	"context"

	"group/internal/svc"
	"group/pb/group"

	"github.com/zeromicro/go-zero/core/logx"
)

type DeleteMemberLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewDeleteMemberLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteMemberLogic {
	return &DeleteMemberLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// DeleteMember 群聊成员删除(移除群成员/群成员退群)
func (l *DeleteMemberLogic) DeleteMember(in *group.DeleteMemberRequest) (*group.Empty, error) {
	err := l.svcCtx.ChatGroupAggregationModel.DeleteMember(l.ctx, in.HandlerUserId, in.UserId, in.GroupId)
	if err != nil {
		return nil, err
	}
	return &group.Empty{}, nil
}
